package com.zj.study;

import com.zj.study.Test01.UserVo;
import com.zj.study.entity.User;
import com.zj.study.utils.beancopier.BeanCopier;
import java.time.LocalDateTime;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author 赵赳
 * @since 2021/9/26 17:35
 */
public class UserTransferFunction implements Function<List<User>,List<UserVo>> {

  public static final UserTransferFunction DEFAULT = new UserTransferFunction();

  @Override
  public List<UserVo> apply(List<User> source) {
    var collect = source.stream().map(t -> BeanCopier.copy(t, UserVo.class)
        .setCreateTime(LocalDateTime.now())
        .setUpdateTime(LocalDateTime.now())
        .setDelFlag(0)
        .setVersion(1))
        .collect(Collectors.toList());
    System.out.println("user对象转换器执行。。。");
    return collect;
  }


}
